//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "SettingsSF.h"
#include "MainSF.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "AdvToolBar"
#pragma link "AdvToolBarStylers"
#pragma link "AdvDirectoryEdit"
#pragma link "AdvEdBtn"
#pragma link "AdvEdit"
#pragma resource "*.dfm"
TSettings *Settings;
//---------------------------------------------------------------------------
__fastcall TSettings::TSettings(TComponent* Owner)
	: TAdvToolBarForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TSettings::FormClose(TObject *Sender, TCloseAction &Action)
{
	Main->tb1->Enabled=true;
	Action=caFree;
}
//---------------------------------------------------------------------------

void __fastcall TSettings::edtDirChange(TObject *Sender)
{
	std::wofstream fDirPath( "DirPath.txt", ios::out|ios::trunc);
	fDirPath.imbue(std::locale(".1251"));
	fDirPath<<edtDir->Text.t_str();
	fDirPath.close();
}
//---------------------------------------------------------------------------

void __fastcall TSettings::FormShow(TObject *Sender)
{
	ifstream ifDirPath("DirPath.txt",ios::in|ios::binary);
	if (!ifDirPath.bad())
	{
		ifDirPath.imbue(std::locale(".1251"));
		ifDirPath.seekg (0, ios::end);
		int length= ifDirPath.tellg();
		ifDirPath.seekg (0, ios::beg);
		char * buff = new char [length];
		ifDirPath.getline(buff, length+1);
		edtDir->Text=buff;
		delete[] buff;
		ifDirPath.clear();
		ifDirPath.close();
	}
	else
	{
		edtDir->Text="D:/Reports";
	}
}
//---------------------------------------------------------------------------

